import { createStore } from 'vuex'
import createPersistedState from "vuex-persistedstate"
import axios from 'axios';
export default createStore({
  state: {
    courseNotesData:[],
    options:[],
    token: "",
    routeName:'',
    subjectData:null,
    questionBank:{
      subjectModel:{
        subjectTypeNameArray:[],
        subjectTypeTreeData:null,
        subjectTableData:[],
        subjectPagination:{
          total:null,
          pageNum:1,
          pageSize:5,
          accountTypeId:0,
          subjectTypeId:0,
          status:0,
          subjectTypeList:[],
          
        }
        ,subjectTable:{
          selectList:[]
        },
        testPaperTableData:null,
        testPaperPagination:{
          total:0,
          pageNum:1,
          pageSize:10,
          accountTypeId:0,
          testPaperTypeId:0,
          status:0,

        },
        testPaperTypeList:[],
        userSelectTestPaper:[]
      }
    },
    user:{
      userId:"",
      roleId:"",
      phone:"",
      sex:"",
      emali:"",
      userName:"",
      userPermissions:[]
    
    }
  },
  getters: {
  },
  mutations: {
    settoken(s,t){
      s.token = t;
    },
    setterUser(s,t){
      s.user = t
    },
    clearUser(s,t){
      s.user = null;
      console.log(s.user)
    },
    insertData(state,data){
      state.subjectData = data
    },
    insertSubjectPageTreeData(state,data){
      state.questionBank.subjectModel.subjectTypeTreeData = data
    },
    selectSubjectTableData(state,data){
      state.questionBank.subjectModel.subjectTableData = data
    },
    selectSubjectTableTotal(state,data){
      state.questionBank.subjectModel.subjectPagination.total = data
    },
    selectAccountTypeId(state,data){
      state.questionBank.subjectModel.subjectPagination.accountTypeId = data
    },
    selectSubjectTypeId(state,data){
      state.questionBank.subjectModel.subjectPagination.subjectTypeId = data
    }
    ,selectSubjectTablePageNum(state,data){
      state.questionBank.subjectModel.subjectPagination.pageNum = data
    }
    ,selectSubjectTablePageSize(state,data){
      state.questionBank.subjectModel.subjectPagination.pageSize = data
    },
    selectSubjectStatus(state,data){
      state.questionBank.subjectModel.subjectPagination.status = data
    },
    selectSubjectTypeList(state,data){
      state.questionBank.subjectModel.subjectPagination.subjectTypeList = data
    },
    selectListSubjectOfTable(state,data){
      state.questionBank.subjectModel.subjectTable.selectList = data
    },
    setTestPaperPagination(state,data){//设置试卷页面分页的值
      state.questionBank.subjectModel.testPaperPagination.total = data.total
      state.questionBank.subjectModel.testPaperPagination.pageNum = data.pageNum
      state.questionBank.subjectModel.testPaperPagination.pageSize = data.pageSize
      state.questionBank.subjectModel.testPaperPagination.accountTypeId = data.accountTypeId
      state.questionBank.subjectModel.testPaperPagination.testPaperTypeId = data.testPaperTypeId
      state.questionBank.subjectModel.testPaperPagination.status=data.status

  },
  setTestPaperTableData(state,data){//设置试卷数据
    state.questionBank.subjectModel.testPaperTableData = data
  },
    selecttestPaperTypeList(state,data){
      state.questionBank.subjectModel.testPaperTypeList = data
    },
    setuserSelectTestPaper(state,data){
      state.questionBank.subjectModel.userSelectTestPaper = data
    }
    ,
    courseNotesData(state,data){
      state.courseNotesData=data
    },
    options(state,data){
      state.options=data
    }
  },
  actions: {
  },
  modules: {
  },
  plugins: [createPersistedState({
    storage:localStorage,
    reducer(data){
      return {
      token: data.token,
      user:data.user
    }
      }

  })]
})
